function externalInit() {
	
	
	var dsmain = getDataset("todolists_TodoListVO");
	var appoveid = getParameter('approveid');
	var loader = new DatasetLoader(dsmain);
	if(appoveid != null ){
		dsmain.reqParameterMap = new HashMap();
		dsmain.reqParameterMap.put("pk_todolist",appoveid);
	}
	loader.load();
	
	
	//双击数据卡片显示
	getComponent("headTab_TodoListVO_grid").onRowDblClick = function(rowIndex, row){
		billUI.eventHandler.onBoCard();
	}
	
	/**
	 * 调用查询模版进行数据查询
	 *//*
	BillEventHandler.prototype.onBoQuery = function()
	{  	
		var url = getString(this.billUI.billController.queryTemplateUrl, getCorePath() + "/querytemplatecg.jsp?otherPageUniqueId=" + getPageUniqueId() + "&otherPageId=" + getPageId() + "&pageId=" + getPageId() + "_qt&befullname=" + this.getMasterDs().objMeta);
		showDialog(url , trans('ml_qrydialog'), "680", "450", "queryDialogId", false);
	};*/
	
	//主表数据发生变化，需要处理的逻辑定义
	dsmain.onAfterDataChange = function(event){
		/*信托--客商编码*/
		if(event.cellColIndex == this.nameToIndex('pay_name')){
//			var strs = getService("webbx_common_service").getFromHbbmChange(event.currentValue);
//			alert(strs);
			var cmd = new CommonCommand("getFromHbbmChange");
			var reqpara = "pay_name=" + event.currentValue;
			cmd.setParameter(reqpara);
			cmd.setReturnFunc(showReturnmes);
			cmd.exec();
			// 当ajax请求成功后处理进度条和更新界面信息
			function showReturnmes(success) {
			if(success == null){
				dsmain.setValueAt(dsmain.getSelectedIndex(),dsmain.nameToIndex('bank_no'),null,false);
				dsmain.setValueAt(dsmain.getSelectedIndex(),dsmain.nameToIndex('bank_no_mc'),null,false);
				dsmain.setValueAt(event.cellRowIndex,dsmain.nameToIndex('bank_name'),null,false);//信托--开户银行
				dsmain.setValueAt(event.cellRowIndex,dsmain.nameToIndex('bank_name_mc'),null,false);//信托--开户银行
			}else{
				var arr = eval(success);
				var row = dsmain.getSelectedRow();
				dsmain.setValueAt(event.cellRowIndex,dsmain.nameToIndex('bank_no'),arr[0],false);
				dsmain.setValueAt(event.cellRowIndex,dsmain.nameToIndex('bank_no_mc'),arr[1],false);
				dsmain.setValueAt(event.cellRowIndex,dsmain.nameToIndex('bank_name'),arr[2],false);//信托--开户银行
				dsmain.setValueAt(event.cellRowIndex,dsmain.nameToIndex('bank_name_mc'),arr[3],false);//信托--开户银行
			}
			}
		}
	}
	
	
	/*重写PFBillEventHandler*/
	PFBillEventHandler.prototype.returnFunForCheck = function(returnArg, isSuccess, returndoc){
		if(isSuccess){
			var oThis = returnArg[0], headDs = returnArg[1], action = returnArg[2];
			// 如果没有审批流指派，则直接通过，不弹出框
			if(returndoc == 'NOPF'){
				if(action == "commit"){
					billUI.eventHandler.JkbxSaveImpl(null);
				}else if(action == "approve"){
					oThis.commitAudit("", "approve");// 审批通过
				}
			}
			else{
				var paramArr = decodeURIComponent(returndoc).split('#');
				returndoc = paramArr[0];
				window.FlexControlParam = paramArr[1]; 
				
				var meta = headDs.metadata;
				var key = null;
				for(var i = 0, count = meta.length; i < count; i++){
					if(meta[i].isPrimaryKey){
						key = meta[i].key;
						break;
					}
				}	
				//如果有指派信息，则将指派信息放入window参数
				var haveAssign = "N";
				window.assignparams = null;
				if("NO_ASSIGN" != returndoc){
					window.assignparams = returndoc;
					haveAssign = "Y";
				}
				
				if(action == "commit"){
					if(returndoc == 'NO_ASSIGN')
						billUI.eventHandler.JkbxSaveImpl(null);
					else{
						var url = getCorePath() + "/assign/assign.jsp?pageId=assign"
								  + "&action=" + action
								  + "&rand=" + (Math.random()*10000).toString().substring(0, 4);
						showDialog(url , trans('ml_assigninfo'), "600", "500", "assignable_info_dialog", false,true);
					}
				}
				else if(action == "approve"){
					var billId = headDs.getValue(key);
					var billType = oThis.billUI.billController.billType;
					var url = getCorePath() + "/approve/approve.jsp?pageId=approve&billType=" + billType + "&billId=" 
							+ billId + "&haveAssign=" + haveAssign;
					showDialog(url , trans('ml_approvedialog'), "600", "450", "approveDialogId", false);
				}
			}
		}
	};
	
	PFBillEventHandler.prototype.afterAction = function(actionType)
	{
		if(actionType == "APPROVE"){
			alert("审批通过");
		}else if(actionType == "SAVE"){
			alert("提交成功");
		}
	};
	
	
	/*//具体实现保存的方法
	PFBillEventHandler.prototype.JkbxSaveImpl = function(pksmap){
		var oThis = this;
		var headDs = this.getMasterDs();
		var allSubDsArr = this.getAllSlaveDs();
		if(headDs != null)
			headDs.reqParameterMap.clear();
		for(var i = 0;i < allSubDsArr.length; i++) {
			if(allSubDsArr[i] != null)
	       		allSubDsArr[i].reqParameterMap.clear();
		}
		var sRow = headDs.getSelectedRow();
		// 设置单据状态为【提交】(因为财务的保存和提交是一块的)
//		sRow.setCellValue(headDs.nameToIndex(billUI.billController.billStatusField), this.getBillStatusValue("COMMIT"));
		// 显示进度提示对话框
		showProgressDialog(trans('ml_wait'));
		
		//保存时可传递参数
		if(typeof window.objs == 'undefined')
			window.objs = null;
		var saver = new DatasetSaver();
		saver.setMasterDs(headDs);
		saver.setMasterRow(sRow);
		saver.setDetailDsArray(allSubDsArr);
		saver.setHaveDsRelation(true);
		saver.setReturnFunc(this.WebbxPfSaveShowDialog);
		saver.setReturnArgs([this,headDs]);
		saver.setSaveParam("obj=" + window.objs +"&ASSIGN_INFO=" + pksmap);
		saver.save();
		
	};
	PFBillEventHandler.prototype.WebbxPfSaveShowDialog = function(args, isSuccess)
	{
		hideProgressDialog();
		var oThis = args[0];
		var headDs = args[1];
		oThis.saveSucessFun(args, isSuccess);
		log("PF--->成功执行完saveSunccessFun()函数");
		if(isSuccess){	
			// 正确执行完保存操作后,对所有的Dataset进行clearState操作
			oThis.callAllDsClearStatus();
		    oThis.billUI.setTotalUIStatus(IBillOperate.OP_NOTEDIT);
		    if(oThis.afterAction(IPfAction.COMMIT) == false)
				return;
		    window.objs = null;
		}else{
			headDs.setValueAt(headDs.getSelectedIndex(),headDs.nameToIndex('djzt'),null);
		}
			
		oThis.onAfterBoSave();
	    log("PF保存执行完毕");	
	};
	
	billUI.eventHandler.onBoSave =function(){
		if(window.$refEnterCount != null && window.$refEnterCount != 0){
			window.$pfsaveRt = setTimeout("PFBillEventHandler.delaySave()", 50);
			return;
		}  
		var oThis = this;
		var headDs = this.getMasterDs();
		var allSubDsArr = this.getAllSlaveDs();
	    log("PF--->进入PFBillEventHandler.onBoSave()方法.");  
		if(!this.isNeedSave([headDs]) && !this.isNeedSave(allSubDsArr)) {
			if(!this.isTmpSaveStatus(headDs)){//是否时暂存态 保存，暂存态可以不修改直接保存
			    showMessageDialog(trans("ml_nooperation"));
			    return;
			}
		} 
		if(headDs != null)
			headDs.reqParameterMap.clear();
	     
		for(var i = 0;i < allSubDsArr.length; i++) {
			if(allSubDsArr[i] != null)
	       		allSubDsArr[i].reqParameterMap.clear();
		}
		var sRow = headDs.getSelectedRow();
	   	// 主表校验不过,则不提交
	   	if(!this.checkMasterDs(headDs, sRow))
	   		return;
	   	// 对所有子表进行提交前校验,如果校验不过,则不提交	
	   	if(!this.checkDetailDs(allSubDsArr))
	   		return;
		log("PFonBoSave方法中执行onbeforeAction()之前...");
		if(this.beforeAction(IPfAction.COMMIT) == false)
			return;
		log("PFonBoSave方法中执行完onbeforeAction()之后...");
		
		//保存前检查是否有指派
		oThis.checkIsAssign(headDs,allSubDsArr,"commit"); 
	}*/
	
	
}

/**
 * 页面参数
 * @return 
 */
function setPageParamMap(key,value){
	if(window.PageParamMap == null)
		window.PageParamMap = new HashMap();
	window.PageParamMap.put(key,value);
}
function getPageParamByKey(key){
	if(window.PageParamMap != null)
		return window.PageParamMap.get(key);
}

function setToObject(key,value){
	window[key] = value;
}
function getFromObject(key){
	return window[key];
}
 
function setCheckManMap(key,value){
	if(window.CheckManMap == null)
		window.CheckManMap = new HashMap();
	window.CheckManMap.put(key,value);
}
function getCheckManByKey(key){
	if(window.CheckManMap != null)
		return window.CheckManMap.get(key);
}
function clearCheckManMap(){
	if(window.CheckManMap != null)
		window.CheckManMap.clear();
}



//联查审批情况
function selfDefBtnFuc(btnNo){   
	var ds = billUI.getEventHandler().getMasterDs();
	var row = ds.getSelectedRow();
	if(btnNo.name == 211){
		//联查审批情况
		
		if(row == null){
			showMessageDialog("请选择要联查的业务项！");
			return;
		}
		var billId = row.getCellValue(ds.nameToIndex("pk_todolist"))
		var billType = row.getCellValue(ds.nameToIndex("pk_billtype"));
		var url = getCorePath() + "/pfinfo/pfinfo.jsp?pageId=pfinfo&billId="+ billId +"&billType=" + billType + "&rand=" + (Math.random()*10000).toString().substring(0, 4);
		showDialog(url , "联查审批情况", "985", "450", "pfinfoDialog", true,true);
	}else if(btnNo.name == 203){
		var pk_todo_list = row.getCellValue(ds.nameToIndex('pk_todolist'));
		var url = getCorePath() + "/reqdocmanage/docmanage.jsp?pageId=reqdocmanage" 
				+ "&pk_jkbx=" + pk_todo_list
				+ "&rand=" + (Math.random()*10000).toString().substring(0, 4);
		showDialog(url , "文档管理", "550", "350", "attachmentDialog", true,true);
	}else if(btnNo.name == 202){
		var pk_todo_list = row.getCellValue(ds.nameToIndex('pk_todolist'));
		var billstatus = row.getCellValue(ds.nameToIndex('billstatus'));
		if(billstatus != 1){
			showMessageDialog("请审批通过之后进行操作!");
			return;
		}
		var drawOutCommand = new CommonCommand("sendOrder");
		var reqpara = "pk_todolist=" + pk_todo_list;
		drawOutCommand.setParameter(reqpara);
		drawOutCommand.setReturnFunc(showReturnValue);
		drawOutCommand.exec();

		// 当ajax请求成功后处理进度条和更新界面信息
		function showReturnValue(success) {
			if (success == 'ok') {
				// yanlei 保存成功
				// 显示资金申请单的卡片形式
				var pk_bx = row.getCellValue(ds.nameToIndex('pk_todolist'));
				if(pk_bx == null){
					showMessageDialog("生成资金申请单失败!");
					return;
				}
				
				var url = getCorePath() + "/bxmanageui.jsp?model=nc.lfw.finance.model.BxDJBasePageModel&ctrl=nc.lfw.finance.ctrl.BXManageController&delegator=nc.lfw.finance.delegator.BxDjDelegator&pageId=E01002XX07" 
						+ "&pk_bx=" + pk_bx + "&fromType=2648"
						+ "&rand=" + (Math.random()*10000).toString().substring(0, 4);
				showDialog(url , "资金申请单", "900", "600", "attachmentDialog", true,true);
				//showMessageDialog("生成成功,请到资金申请单进行查看!");
			} else if(success == 'isclosed'){
				showMessageDialog("事项单已关闭，无法生成资金申请单！");
			}else {
				showMessageDialog("调用失败");
			}
		}
	}else if(btnNo.name == 220){
		var dsmain = getDataset("todolists_TodoListVO");
		var loader = new DatasetLoader(dsmain);
		dsmain.reqParameterMap = new HashMap();
		dsmain.reqParameterMap.put("nowwork","nowwork");
		loader.load();
	}if(btnNo.name == 922) //导出excel
	{
		if(row == null){
			showMessageDialog("请选择要打印数据！");
			return;
		}
		var pk_todo_list = row.getCellValue(ds.nameToIndex('pk_todolist'));
		//window.location.href = "/yer/exceldownload?pk="+pk_todo_list+"&key=E0100205&classpath=nc.ebs.exportexcel.ExcelPlan";
		window.location.href = "/yer/txtfiledownload?pk="+pk_todo_list+"&key=E0100205";
		}
}

function getFromtype(){ 
	return "todolist";
}